package com.datastructure.test.constructormultiplyarray;

public class ConstructorMultiplyArray {

    public static void main(String[] args) {

    }

    public int[] multiply(int[] A) {
        if(A==null||A.length==1){
            return A;
        }
        int[] result = new int[A.length];
        for (int i = 0; i < result.length; i++) {
            int temp = 1;
            for (int j = 0; j < A.length; j++) {
                if(j!=i){
                    temp*=A[j];
                    if(temp==0){
                        break;
                    }
                }
            }
            result[i]=temp;
        }
        return result;
    }
}
